package net.opentsdb.core;

import cn.hutool.core.date.DateTime;
import com.stumbleupon.async.Deferred;
import net.opentsdb.stats.QueryStats;
import net.opentsdb.tsd.Query;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author hujf
 * @Date 2022/3/1 10:28
 * @Description 查询实体
 */
public class TSQuery {

    private String start;
    private String end;
    private String timezone;

    private long startTime;

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }

    private long endTime;

    public List<TSSubQuery> getQueries() {
        return queries;
    }

    public void setQueries(List<TSSubQuery> queries) {
        this.queries = queries;
    }

    private List<TSSubQuery> queries;

    public String getStart() {
        return start;
    }

    public void setStart(String start) {
        this.start = start;
    }

    public String getEnd() {
        return end;
    }

    public void setEnd(String end) {
        this.end = end;
    }

    public String getTimezone() {
        return timezone;
    }

    public void setTimezone(String timezone) {
        this.timezone = timezone;
    }

    public void validateAndSetQuery() {

    }

    private QueryStats queryStats;

    public void setQueryStats(QueryStats queryStats) {
        this.queryStats = queryStats;
    }

    public QueryStats getQueryStats() {
        return queryStats;
    }

    public Deferred<Query[]> buildQueriedAsync(TSDB tsdb) {
        Query[] tsdb_queries = new Query[queries.size()];

        List <Deferred<Object>> deferreds = new ArrayList<>(queries.size());

        for(int i=0;i<queries.size();i++){
            Query query = tsdb.newQuery();
            deferreds.add(query.configureFromQuery(this,i));
        }

       // return tsdb.metrics.getIdAsync();
        return null;
    }
}
